ServerPlayNetworkContext

class ServerPlayNetworkContext(context: ServerPlayNetworking.Context) : NetworkContext<ServerPlayerEntity>

A server-side network context, used to handle C2S payloads

Author

fzzyhmstrs

Since

0.4.1

Constructors

Link copied to clipboard
constructor(context: ServerPlayNetworking.Context)

Functions

Link copied to clipboard
open override fun canReply(id: Identifier): Boolean

Check for whether you can reply with a certain payload type (Typically this is CustomPayload.Id#id)

Link copied to clipboard
open override fun disconnect(reason: Text)

Disconnects the current session (single or multiplayer)

Link copied to clipboard
open override fun execute(runnable: Runnable)

Executes a task on the main thread. This should be used for anything interacting with game state outside the network loop

Link copied to clipboard
open override fun networkPhase(): NetworkPhase

The current network phase. Always PLAY at the moment.

Link copied to clipboard
open override fun networkSide(): NetworkSide

The network side of this context. Responses will be CLIENTBOUND

Link copied to clipboard
open override fun player(): ServerPlayerEntity

The player entity associated with this context. A server player in this case.

Link copied to clipboard
open override fun reply(payload: CustomPayload)

Replies to a payload with an opposite-direction response (S2C in this case)

Link copied to clipboard
fun sendToAllPlayers(payload: CustomPayload, skipCurrentPlayer: Boolean = true)

Sends a payload to all players on the server. By default, skips the player that sent the inbound packet